package squarePackage;

import static org.junit.Assert.*;
import java.math.BigDecimal;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import Enumerations.Directions;
import Obstacle.Door;
import Obstacle.Wall;


/**
 * @version 24/3/2011 20.42
 * @author An
 *
 */
public class RockSquareTest {

	/**
	 * @throws java.lang.Exception
	 */
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		square = new RockSquare();
		
	}

	public Square square;
	
	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
	}
	
	@Test
	public final void constructor(){
		Square testSquare = new RockSquare();
		assertEquals(6, testSquare.hasNumberBorders());
		assertEquals(0, testSquare.getTemperature(),0);
		assertEquals(new BigDecimal("0"),testSquare.getHumidity());
	}
	
	@Test
	public final void isValidHumidity0(){
		assertTrue(square.isValidHumidity(new BigDecimal("0")));
		assertTrue(square.isValidHumidity(new BigDecimal("0.00")));
		assertFalse(square.isValidHumidity(new BigDecimal("4")));
		assertFalse(square.isValidHumidity(null));
	}
	
	@Test
	public final void isValidBorder(){
		assertTrue(square.isValidBorder(Directions.North, new Wall()));
		assertFalse(square.isValidBorder(Directions.South, new Wall(new Door())));
	}
	
	@Test (expected = UnsupportedOperationException.class)
	public void deleteBorder(){
		square.deleteBorder(Directions.North);
	}
}
